#ifndef _THREAD_ENUMERATOR_IMPL_H_
#define _THREAD_ENUMERATOR_IMPL_H_

#include "tools/HandleWraper.h"

#include<boost/thread.hpp>
#include<Windows.h>

namespace sd
{
namespace tools
{

/*
	On windows system load process threads is VERY slowly operation
*/

namespace thread_enumerator
{
namespace impl
{
	typedef std::vector<int> Threads;
	typedef Threads::const_iterator iterator;

class ProcessThreadEnumeratorImpl
{
public:
	ProcessThreadEnumeratorImpl(){ openProcess(0); }
	ProcessThreadEnumeratorImpl( int process ){ openProcess(process); }
	ProcessThreadEnumeratorImpl( const HHANDLE& handle ){ attachProcess(handle); }

	void reload();

	iterator begin()const{ return threads_.begin(); }
	iterator end()const{ return threads_.end(); }
private:
	void openProcess( int processId );
	void attachProcess( const HHANDLE& );

	Threads threads_;
	int processID_;
};




}//impl
}//thread_enumerator
}//tools
}//sd









#endif //THREAD_ENUMERATOR_H_